package com.yuantu.judiciary.controller;

import com.yuantu.judiciary.common.Response;
import com.yuantu.judiciary.common.ResponseFactory;
import com.yuantu.judiciary.model.form.GetStatisticsCountForm;
import com.yuantu.judiciary.model.form.GetStatisticsForm;
import com.yuantu.judiciary.model.vo.*;
import com.yuantu.judiciary.service.IConsoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制台
 *
 * @author syw
 * @since 2023-09-01
 **/
@RestController
@RequestMapping(value = "/console")
@Api(tags = "控制台")
@RequiredArgsConstructor
public class ConsoleController {

    private final IConsoleService consoleService;

    @ApiOperation(value = "获取新增用户统计")
    @PostMapping("/statistics/new-user")
    public Response<StatisticsNewUserVO> getNewUserStatistics(@RequestBody @Validated GetStatisticsForm form) {
        return ResponseFactory.okResponse(consoleService.getNewUserStatistics(form));
    }

    @ApiOperation(value = "获取收费统计")
    @PostMapping("/statistics/charge")
    public Response<StatisticsChargeVO> getChargeStatistics(@RequestBody @Validated GetStatisticsForm form) {
        return ResponseFactory.okResponse(consoleService.getChargeStatistics(form));
    }

    @ApiOperation(value = "获取用户占比")
    @GetMapping("/proportion/user")
    public Response<ProportionUserVO> getUserProportion() {
        return ResponseFactory.okResponse(consoleService.getUserProportion());
    }

    @ApiOperation(value = "获取收费占比")
    @GetMapping("/proportion/charge")
    public Response<ProportionChargeVO> getChargeProportion() {
        return ResponseFactory.okResponse(consoleService.getChargeProportion());
    }

    @ApiOperation(value = "获取套餐购买占比")
    @GetMapping("/proportion/vip")
    public Response<List<ProportionVipVO>> getVipProportion() {
        return ResponseFactory.okResponse(consoleService.getVipProportion());
    }

    @ApiOperation(value = "获取组织列表")
    @GetMapping("/org/list")
    public Response<List<OrgSimpleVO>> getOrgList() {
        return ResponseFactory.okResponse(consoleService.getOrgList());
    }

    @ApiOperation(value = "接口统计次数")
    @PostMapping("/statistics/interface/count")
    public Response<StatisticsCountVO> getCountStatistics(@RequestBody @Validated GetStatisticsCountForm form) {
        return ResponseFactory.okResponse(consoleService.getCountStatistics(form));
    }

}
